package com.example.moviecms2.controller;

import com.example.moviecms2.domain.Actor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 测试控制器类
 */
@Controller
@RequestMapping(value = "/hello")
public class HelloController {

    @RequestMapping(value = "/test", method = RequestMethod.GET)
    public void test() {
        System.out.println("this is HelloController test method.");
    }

    @RequestMapping(value = "/test2/{id}")
    public void test2(@PathVariable String id) {
        System.out.println(">>>>>>>>>>>>>>>>>>>" + id);
    }

    @ResponseBody
    @RequestMapping(value = "/abc/{id}/{name}")
    public Actor test3(@PathVariable Long id, @PathVariable String name) {
        System.out.println(">>>>>>>>>>>  test3");
        Actor actor = new Actor();
        actor.setId(id);
        actor.setName(name);
        return actor;
    }

    @RequestMapping(value = "/say",method = RequestMethod.GET)
    public String say(Model model){
        model.addAttribute("greet","Hello Thymeleaf");
        return "hello/say";
    }
}
